package com.cupk.mapper;

import com.cupk.pojo.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface UserMapper {
    @Insert("insert into user(name,role,account,password,avatar)" + "values(#{name},#{role},#{account},#{password},#{avatar})")
    void register(User user);

    @Select("select * from user where account = #{account}")
    User getUserByAccount(String account);

    @Select("select * from user where email = #{email}")
    User getUserByEmail(String email);

    @Update("update user set email = #{email} where id = #{userId}")
    void updateEmailById(String userId, String email);

    @Update("update user set password = #{password} where id = #{userId}")
    void updatePasswordById(String userId, String password);

    @Select("select * from user  where name = #{name}")
    User getUserByName(String name);
}
